wayland: Implement GdkDevice::window_at_position for touch
authorCarlos Garnacho <carlosg@gnome.org>
Thu, 19 Nov 2015 19:23:44 +0000 (20:23 +0100)
committerCarlos Garnacho <carlosg@gnome.org>
Thu, 19 Nov 2015 22:26:48 +0000 (23:26 +0100)
This goes through its own master pointer, so look up the pointer
emulating touch focus window and coordinates.

gdk/wayland/gdkdevice-wayland.c

index 58f5b9ef772f18b73c9f2a1b69e9bbb4124a4c47..cce562e905cdccc31c2c1dd63fa8dc8d28d9ada4 100644 (file)
@@ -595,16 +595,45 @@ gdk_wayland_device_window_at_position (GdkDevice       *device,
                                        gboolean         get_toplevel)
 {
   GdkWaylandDeviceData *wd;
+  GdkWindow *window = NULL;
 
   wd = GDK_WAYLAND_DEVICE(device)->device;
-  if (win_x)
-    *win_x = wd->surface_x;
-  if (win_y)
-    *win_y = wd->surface_y;
+
+  if (device == wd->master_pointer)
+    {
+      if (win_x)
+        *win_x = wd->surface_x;
+      if (win_y)
+        *win_y = wd->surface_y;
+
+      if (mask)
+        *mask |= wd->button_modifiers;
+
+      window = wd->pointer_focus;
+    }
+  else if (device == wd->touch_master)
+    {
+      GdkWaylandTouchData *touch;
+
+      touch = GDK_WAYLAND_DEVICE(device)->emulating_touch;
+
+      if (touch)
+        {
+          if (win_x)
+            *win_x = touch->x;
+          if (win_y)
+            *win_y = touch->y;
+          if (mask)
+            *mask |= GDK_BUTTON1_MASK;
+
+          window = touch->window;
+        }
+    }
+
   if (mask)
-    *mask = wd->button_modifiers | wd->key_modifiers;
+    *mask = wd->key_modifiers;
 
-  return wd->pointer_focus;
+  return window;
 }
 
 static void